<template>
  <el-card shadow="always" :body-style="{padding:20}">
    <el-form :inline="true">
      <el-row>
        <el-col :span="8">
          <el-form-item label="一级分类">
            <el-select placeholder="一级分类" v-model="cateStore.state.c1Id" @change="c1Change" :disabled="sene==1?false:true">
              <el-option :label="c1.name" :value="c1.id" v-for="(c1,index) in cateStore.state.c1List" :key="index"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="二级分类">
            <el-select placeholder="二级分类" v-model="cateStore.state.c2Id" @change="c2Change"  :disabled="sene==1?false:true">
              <el-option :label="c2.name" :value="c2.id" v-for="(c2,index) in cateStore.state.c2List" :key="index"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="三级分类">
            <el-select placeholder="三级分类" v-model="cateStore.state.c3Id"  :disabled="sene==1?false:true" >
              <el-option :label="c3.name" :value="c3.id" v-for="(c3,index) in cateStore.state.c3List" :key="index"></el-option>
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
  </el-card>
</template>

<script setup lang="ts">
import {onMounted, onUnmounted, ref} from 'vue'
import useCategoryStore from '@/stores/category'
defineProps(['sene'])
const cateStore = useCategoryStore()
 onMounted(()=>{
    cateStore.reqCate1()
 })
 const c1Change = ()=>{
     cateStore.reqCate2()
 }
 const c2Change = ()=>{
    cateStore.reqCate3()
 }
 onUnmounted(()=>{
      cateStore.state.c1Id=''
      cateStore.state.c2Id=''
      cateStore.state.c3Id=''
      cateStore.state.c1List=[]
      cateStore.state.c2List=[]
      cateStore.state.c3List=[]
 })
</script>

<style scoped>
</style>